package com.bjhb.wuranyuan.web.action;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bjhb.wuranyuan.dao.QyxxMapper;
import com.bjhb.wuranyuan.dao.XzqhMapper;
import com.bjhb.wuranyuan.pojo.Qyxx;
import com.bjhb.wuranyuan.pojo.Xzqh;

@Controller
public class QyxxAction {

	@Resource
	private QyxxMapper qyxxMapper;
	@Resource
	private XzqhMapper xzqhMapper;

	@RequestMapping("/qyxx.htm")
	public String list(HttpServletRequest request) {
		List<Qyxx> qyxxs = qyxxMapper.query();
		List<Xzqh> xzqhs = xzqhMapper.query();
		request.setAttribute("xzqhs", xzqhs);
		request.setAttribute("list", qyxxs);
		return "qyxx";
	}

	@RequestMapping("/qyxx/delete.htm")
	public void delete(HttpServletResponse resp, String[] qydms) {
		if (qydms != null && qydms.length > 0) {
			for (String qydm : qydms) {
				qyxxMapper.delete(qydm);
			}
		}
		try {
			resp.sendRedirect("../qyxx.htm");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
